home *** CD-ROM | disk | FTP | other *** search
- global cBoundSprite, cGridSprite, cGridL, cGridT, cGridSpace, cHalfGridSpace, cGridHList, cGridVList, gTileTrackList, gTileLocList, cShadowSprite, cFloatSprite, gTileObjList, cTileOffset, cRightEdge, cBottomEdge, cHandCursor, cFingerCursor, cFistCursor, gLastRollover
-
- on initPuzzle
- setPuzzleConstants()
- setPuzzleGlobals()
- puppetSprite(cShadowSprite, 1)
- puppetSprite(cFloatSprite, 1)
- set the randomSeed to the ticks
- puppetTempo(120)
- end
-
- on setPuzzleConstants
- set cBoundSprite to 1
- set cGridSprite to 2
- set cTileOffset to 11
- set cGridL to the left of sprite cGridSprite
- set cGridT to the top of sprite cGridSprite
- set cGridSpace to 50
- set cHalfGridSpace to cGridSpace / 2
- set cShadowSprite to 47
- set cFloatSprite to 48
- set cRightEdge to the stageRight - the stageLeft
- set cBottomEdge to the stageBottom - the stageTop
- set cHandCursor to [the number of member "Hand", the number of member "Hand Mask"]
- set cFingerCursor to [the number of member "Finger", the number of member "Finger Mask"]
- set cFistCursor to [the number of member "Fist", the number of member "Fist Mask"]
- end
-
- on setPuzzleGlobals
- set cGridHList to [:]
- set cGridVList to [:]
- set firstPointH to cGridL + cHalfGridSpace
- set firstPointV to cGridT + cHalfGridSpace
- addProp(cGridHList, firstPointH, firstPointH)
- addProp(cGridVList, firstPointV, firstPointV)
- repeat with x = 1 to 3
- set HLoc to firstPointH + (x * cGridSpace)
- addProp(cGridHList, HLoc, HLoc)
- set VLoc to firstPointV + (x * cGridSpace)
- addProp(cGridVList, VLoc, VLoc)
- end repeat
- sort(cGridHList)
- sort(cGridVList)
- set gTileTrackList to ["11": EMPTY, "12": EMPTY, "13": EMPTY, "14": EMPTY, "21": EMPTY, "22": EMPTY, "23": EMPTY, "24": EMPTY, "31": EMPTY, "32": EMPTY, "33": EMPTY, "34": EMPTY, "41": EMPTY, "42": EMPTY, "43": EMPTY, "44": EMPTY]
- set gTileLocList to []
- repeat with i = 1 to 16
- append(gTileLocList, the loc of sprite (i + cTileOffset))
- end repeat
- set shuffleList to ListShuffler(16)
- set gTileObjList to []
- repeat with i = 1 to 16
- set whichSprite to i + cTileOffset
- puppetSprite(whichSprite, 1)
- set whichMem to the name of cast the castNum of sprite whichSprite
- add(gTileObjList, new(script "Tile Parent Script", whichSprite, whichMem))
- set whichNum to getAt(shuffleList, i)
- set the loc of sprite whichSprite to getAt(gTileLocList, whichNum)
- end repeat
- end
-
- on moveTile
- set whichSprite to the clickOn
- set whichTileObj to whichSprite - cTileOffset
- dragTile(getAt(gTileObjList, whichTileObj))
- checkForWin()
- end
-
- on checkForWin
- set checkNum to 0
- repeat with x = 1 to count(gTileTrackList)
- set checkProp to getPropAt(gTileTrackList, x)
- set checkValue to getAt(gTileTrackList, x)
- if checkProp = checkValue then
- set checkNum to checkNum + 1
- next repeat
- end if
- exit
- end repeat
- if checkNum = 16 then
- pupsOff()
- cursor(-1)
- go("Clock")
- end if
- end
-
- on ListShuffler howMany
- set shuffleList to []
- repeat with x = 1 to howMany
- addAt(shuffleList, x, x)
- end repeat
- repeat with x = 1 to howMany
- set randVar to random(howMany)
- set TempVar to getAt(shuffleList, x)
- set a to getAt(shuffleList, randVar)
- setAt(shuffleList, x, a)
- setAt(shuffleList, randVar, TempVar)
- end repeat
- return shuffleList
- end
-
- on pupsOff
- repeat with x = 1 to 48
- puppetSprite(x, 0)
- end repeat
- end
-
- on checkRoll
- repeat with spriteCounter = 10 to 27
- set gLastRollover to 46
- cursor(-1)
- if rollOver(spriteCounter) and (spriteCounter <> gLastRollover) then
- set gLastRollover to spriteCounter
- if (spriteCounter = 10) or (spriteCounter = 11) then
- cursor(cFingerCursor)
- else
- cursor(cHandCursor)
- end if
- repeat while rollOver(spriteCounter) and the mouseUp
- end repeat
- exit repeat
- end if
- end repeat
- end
-